// 构建消费者
const amqp = require('amqplib');
const config = require('../../config/dev')
let connection = null;

async function initConnection() {
    return new Promise(((resolve, reject) => {
        amqp.connect(`amqp://${config.rabbitmq.hostname}:${config.rabbitmq.port}`).then(conn => {
            connection = conn;
            console.log('rabbitmq connect init success');
            return resolve(connection);
        })
    }))

}

module.exports = {
    initConnection
}
